﻿using B.S.ReportEvent.ErrorCode;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace B.S.ReportEvent.Infrastructure.Interfaces
{
    public interface IBaseRepository<T> where T : class
    {
        //Task<int> AddAsync(T entity);

        //IQueryable<T> Query(Expression<Func<T, bool>> expression);

        //Task<T> GetAsync(Expression<Func<T, bool>> expression);


        //Task<int> DelAsync(T entity);

        //Task<int> UpdateAsync(T entity);
        /// <summary>
        /// 多条件查询
        /// </summary>
        /// <returns></returns>
        IQueryable<T> GetAll();
        /// <summary>
        /// 单条件查询
        /// </summary>
        /// <param name="expression"></param>
        /// <returns></returns>
        Task<T?> GetAsync(Expression<Func<T, bool>> expression);
        /// <summary>
        /// long编号查询
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<T?> GetByIdAsync(long id);
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        Task<int> AddAsync(T entity);
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        Task<int> UpdateAsync(T entity);
        /// <summary>
        /// 批量修改
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        Task<int> UpdateRangeAsync(IList<T> tlist);
        /// <summary>
        /// 分页
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="expression"></param>
        /// <returns></returns>
        Task<PagingResult<T>> GetPageListAsync(int pageIndex, int pageSize, Expression<Func<T,bool>>? expression=null);
        /// <summary>
        /// 批量添加
        /// </summary>
        /// <param name="tlist"></param>
        /// <returns></returns>
        Task<int> AddRangeAsync(IList<T> tlist);

    }
}
